%  bloques.sty
%       package based on tikz for control diagrams in power electronics.
%       version 1.0
% 	    author:  Alejandro Garces
%		            alejandrogarces@gmail.com
% License: LPPL
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
% of this license or (at your option) any later version.
% The latest version of this license is in
%   http://www.latex-project.org/lppl.txt
% and version 1.3 or later is part of all distributions of LaTeX
% version 2005/12/01 or later.



\usepackage{tikz}
\usepgflibrary{shapes.misc}
\usetikzlibrary{automata,arrows,decorations.pathmorphing,backgrounds,positioning,fit,shadows}

\newcommand{\xdistancia}{1.5cm}
\newcommand{\ydistancia}{1.2cm}
\newcommand{\minaltura}{0.7cm}
\newcommand{\tamano}{\footnotesize}
\newcommand{\colorfondo}{white}
\newcommand{\colortexto}{black}
\newcommand{\colorlinea}{black}
\newcommand{\sombra}{0}
\newcommand{\ancholinea}{thick}

\newcommand{\bShadow}{\renewcommand{\sombra}{1}}
\newcommand{\bColorB}[1]{\renewcommand{\colorfondo}{#1}}
\newcommand{\bColorT}[1]{\renewcommand{\colortexto}{#1}}
\newcommand{\bColorL}[1]{\renewcommand{\colorlinea}{#1}}
\newcommand{\ydistance}[1]{\renewcommand{\ydistancia}{#1}}



\newcommand{\bStart}[1]{\node [] (NODO1) {\tamano{#1}};}

\newcommand{\bPlusDown}[1]{
	\node [draw=\colorlinea, circle,minimum size=1.5em, right of=NODO1, node distance= \xdistancia,\ancholinea, fill=\colorfondo,
	       drop shadow={opacity=\sombra}] (SUMA) {};
  \node [draw=gray!50, cross out, minimum size=1.0em, right of=NODO1, node distance= \xdistancia, thin] {};	
  \node [left of = SUMA, node distance = 0.45em] () { \color{\colortexto}\tiny{$+$}};
  \node [below of = SUMA, node distance = 0.45em] () { \color{\colortexto}\tiny{$+$}};
	\draw [-latex,\colorlinea] (NODO1) -- (SUMA);	
	\node [below of = SUMA, node distance =  \ydistancia] (VARIABLE) {\tamano{#1}};
	\draw [-latex, \colorlinea] (VARIABLE) -- (SUMA);			
	\node  at (SUMA) [anchor = west] (NODO1) {};	
}


\newcommand{\bPlusUp}[1]{
	\node [draw=\colorlinea, circle,minimum size=1.5em, right of=NODO1, node distance= \xdistancia,\ancholinea, fill=\colorfondo,
	       drop shadow={opacity=\sombra}] (SUMA) {};
  \node [draw=gray!50, cross out, minimum size=1.0em, right of=NODO1, node distance= \xdistancia, thin, draw=gray!50] {};	
  \node [left of = SUMA, node distance = 0.45em] () { \color{\colortexto}\tiny{$+$}};
  \node [above of = SUMA, node distance = 0.45em] () { \color{\colortexto}\tiny{$+$}};
	\draw [-latex, \colorlinea] (NODO1) -- (SUMA);	
	\node [above of = SUMA, node distance =  \ydistancia] (VARIABLE) {\tamano{#1}};
	\draw [-latex, \colorlinea] (VARIABLE) -- (SUMA);			
	\node  at (SUMA) [anchor = west] (NODO1) {};	
}

%段宇 2016.1.12三向上加下减，加反馈标记
\newcommand{\bPlusUpMD}[2]{
	\node [draw=\colorlinea, circle,minimum size=1.5em, right of=NODO1, node distance= \xdistancia,\ancholinea, fill=\colorfondo,
	       drop shadow={opacity=\sombra}] (#2) {};
  \node [draw=gray!50, cross out, minimum size=1.0em, right of=NODO1, node distance= \xdistancia, thin, draw=gray!50] {};	
  \node [left of = #2, node distance = 0.45em] () { \color{\colortexto}\tiny{$+$}};
  \node [above of = #2, node distance = 0.45em] () { \color{\colortexto}\tiny{$+$}};
  \node [above of = #2, node distance = -0.45em] () { \color{\colortexto}\tiny{$-$}};
	\draw [-latex, \colorlinea] (NODO1) -- (#2);	
	\node [above of = #2, node distance =  \ydistancia] (VARIABLE) {\tamano{#1}};
	\draw [-latex, \colorlinea] (VARIABLE) -- (#2);			
	\node  at (#2) [anchor = west] (NODO1) {};	
}

%段宇 2016.1.12三向上加下加，加反馈标记
\newcommand{\bPlusUpPD}[2]{
	\node [draw=\colorlinea, circle,minimum size=1.5em, right of=NODO1, node distance= \xdistancia,\ancholinea, fill=\colorfondo,
	       drop shadow={opacity=\sombra}] (#2) {};
  \node [draw=gray!50, cross out, minimum size=1.0em, right of=NODO1, node distance= \xdistancia, thin, draw=gray!50] {};	
  \node [left of = #2, node distance = 0.45em] () { \color{\colortexto}\tiny{$+$}};
  \node [above of = #2, node distance = 0.45em] () { \color{\colortexto}\tiny{$+$}};
  \node [above of = #2, node distance = -0.45em] () { \color{\colortexto}\tiny{$+$}};
	\draw [-latex, \colorlinea] (NODO1) -- (#2);	
	\node [above of = #2, node distance =  \ydistancia] (VARIABLE) {\tamano{#1}};
	\draw [-latex, \colorlinea] (VARIABLE) -- (#2);			
	\node  at (#2) [anchor = west] (NODO1) {};	
}




\newcommand{\bMinusDown}[1]{
	\node [draw=\colorlinea, circle,minimum size=1.5em, right of=NODO1, node distance= \xdistancia,\ancholinea, fill=\colorfondo,
	       drop shadow={opacity=\sombra}] (SUMA) {};
  \node [cross out, minimum size=1.0em, right of=NODO1, node distance= \xdistancia,  thin, draw=gray!50] {};	
  \node [left of = SUMA, node distance = 0.45em] () { \color{\colortexto}\tiny{$+$}};
  \node [below of = SUMA, node distance = 0.45em] () { \color{\colortexto}\tiny{$-$}};
	\draw [-latex,\colorlinea] (NODO1) -- (SUMA);	
	\node [below of = SUMA, node distance =  \ydistancia] (VARIABLE) {\tamano{#1}};
	\draw [-latex,\colorlinea] (VARIABLE) -- (SUMA);			
	\node  at (SUMA) [anchor = west] (NODO1) {};
	
}


\newcommand{\bMinusUp}[1]{
	\node [draw=\colorlinea, circle,minimum size=1.5em, right of=NODO1, node distance= \xdistancia,\ancholinea, fill=\colorfondo,
	       drop shadow={opacity=\sombra}] (SUMA) {};
  \node [thin, cross out, minimum size=1.0em, right of=NODO1, node distance= \xdistancia, draw=gray!50] {};	
  \node [left of = SUMA, node distance = 0.45em] () { \color{\colortexto}\tiny{$+$}};
  \node [above of = SUMA, node distance = 0.45em] () { \color{\colortexto}\tiny{$-$}};
	\draw [-latex, \colorlinea] (NODO1) -- (SUMA);	
	\node [above of = SUMA, node distance =  \ydistancia] (VARIABLE) {\tamano{#1}};
	\draw [-latex, \colorlinea] (VARIABLE) -- (SUMA);			
	\node  at (SUMA) [anchor = west] (NODO1) {};
}

\newcommand{\bEnd}[1]{
	\node [right of = NODO1, node distance = 1.8cm] (F) {#1};
	\draw [-latex,\colorlinea] (NODO1) -- (F);
	\node  at (F) [anchor = west] (NODO1) {};
}


\newcommand{\bGain}[1]{		
	\node [draw=\colorlinea, rectangle, right of = NODO1, node distance= \xdistancia, minimum height = \minaltura, 
	       \ancholinea, fill=\colorfondo,drop shadow={opacity=\sombra}] (NODO2) { \color{\colortexto}\tamano{#1}};	
	\draw [-latex, \colorlinea] (NODO1)--(NODO2);
	\node  at (NODO2.east) [anchor = east] (NODO1) {};	
}

%段宇 2016.1.7 一般增益框后线上加文本
\newcommand{\bGainNext}[1]{\draw (NODO1) +(0.7,0) node [above]{#1};	}

%段宇 2016.1.7 一般增益框前线上加文本
\newcommand{\bGainLine}[2]{		
	\node [draw=\colorlinea, rectangle, right of = NODO1, node distance= 2.5cm, minimum height = \minaltura, 
	       \ancholinea, fill=\colorfondo,drop shadow={opacity=\sombra}] (NODO2) { \color{\colortexto}\tamano{#1}};	
	\draw [-latex, \colorlinea] (NODO1)--(NODO2);
	\draw (NODO1) +(1.0,0) node [above]{#2};
	\node  at (NODO2.east) [anchor = east] (NODO1) {};	
}

%段宇 2016.1.7 大型增益框线上加文本
\newcommand{\bBigGainLine}[2]{		
	\node [draw=\colorlinea, rectangle, right of = NODO1, node distance= 4.0cm, minimum height = \minaltura, 
	       \ancholinea, fill=\colorfondo,drop shadow={opacity=\sombra}] (NODO2) { \color{\colortexto}\tamano{#1}};	
	\draw [-latex, \colorlinea] (NODO1)--(NODO2);
	\draw (NODO1) +(1.8,0) node [above]{#2};
	\node  at (NODO2.east) [anchor = east] (NODO1) {};	
}

%段宇 2016.1.8 超大型增益框
\newcommand{\bBBigGain}[1]{		
	\node [draw=\colorlinea, rectangle, right of = NODO1, node distance= 6.0cm, minimum height = \minaltura, 
	       \ancholinea, fill=\colorfondo,drop shadow={opacity=\sombra}] (NODO2) { \color{\colortexto}\tamano{#1}};	
	\draw [-latex, \colorlinea] (NODO1)--(NODO2);
	\node  at (NODO2.east) [anchor = east] (NODO1) {};
	
	}

%段宇 2016.1.7 大型增益框
\newcommand{\bBigGain}[1]{		
	\node [draw=\colorlinea, rectangle, right of = NODO1, node distance=3.0cm, minimum height = \minaltura, 
	       \ancholinea, fill=\colorfondo,drop shadow={opacity=\sombra}] (NODO2) { \color{\colortexto}\tamano{#1}};	
	\draw [-latex, \colorlinea] (NODO1)--(NODO2);
	\node  at (NODO2.east) [anchor = east] (NODO1) {};
	
}
%段宇 2016.1.7 中型增益框
\newcommand{\bMidGain}[1]{		
	\node [draw=\colorlinea, rectangle, right of = NODO1, node distance=2.0cm, minimum height = \minaltura, 
	       \ancholinea, fill=\colorfondo,drop shadow={opacity=\sombra}] (NODO2) { \color{\colortexto}\tamano{#1}};	
	\draw [-latex, \colorlinea] (NODO1)--(NODO2);
	\node  at (NODO2.east) [anchor = east] (NODO1) {};
	
}

%段宇 2016.1.7 小型增益框
\newcommand{\bSGain}[1]{		
	\node [draw=\colorlinea, rectangle, right of = NODO1, node distance=1.2cm, minimum height = \minaltura, 
	       \ancholinea, fill=\colorfondo,drop shadow={opacity=\sombra}] (NODO2) { \color{\colortexto}\tamano{#1}};	
	\draw [-latex, \colorlinea] (NODO1)--(NODO2);
	\node  at (NODO2.east) [anchor = east] (NODO1) {};
	
}


\newcommand{\bGainPlus}[2]{

	\node [draw=\colorlinea, circle,minimum size=1.5em, right of=NODO1, node distance= \xdistancia,\ancholinea, fill=\colorfondo,
	       drop shadow={opacity=\sombra}] (SUMA) {};
  \node [thin, cross out, minimum size=1.0em, right of=NODO1, node distance= \xdistancia, draw=gray!50] {};	
  \node [left of = SUMA, node distance = 0.45em] () { \color{\colortexto}\tiny{$+$}};
  \node [below of = SUMA, node distance = 0.45em] () { \color{\colortexto}\tiny{$+$}};
	\draw [-latex, \colorlinea] (NODO1) -- (SUMA);	
						
  \node [draw=\colorlinea, rectangle, below of = SUMA, node distance =  \xdistancia,xshift=-0.3cm, minimum height = \minaltura,\ancholinea, 
         fill=\colorfondo,drop shadow={opacity=\sombra}, anchor = east] (NODOG) {\color{\colortexto}\tamano{#2}};
  \node [left of = NODOG, node distance =  \xdistancia] (VARIABLE) {\tamano{#1}};  	
	\draw [-latex, \colorlinea] (VARIABLE) -- (NODOG);
	\draw [-latex, \colorlinea] (NODOG) -| (SUMA);			
	\node  at (SUMA) [anchor = west] (NODO1) {};
}

\newcommand{\bGainMinus}[2]{

	\node [draw=\colorlinea, circle,minimum size=1.5em, right of=NODO1, node distance= \xdistancia,\ancholinea, fill=\colorfondo,
	       drop shadow={opacity=\sombra}] (SUMA) {};
  \node [thin, cross out, minimum size=1.0em, right of=NODO1, node distance= \xdistancia, draw=gray!50] {};	
  \node [left of = SUMA, node distance = 0.45em] () { \color{\colortexto}\tiny{$+$}};
  \node [below of = SUMA, node distance = 0.45em] () { \color{\colortexto}\tiny{$-$}};
	\draw [-latex, \colorlinea] (NODO1) -- (SUMA);	
						
  \node [draw=\colorlinea, rectangle, below of = SUMA, node distance =  \xdistancia,xshift=-0.3cm, minimum height = \minaltura,\ancholinea, 
         fill=\colorfondo,drop shadow={opacity=\sombra}, anchor = east] (NODOG) {\color{\colortexto}\tamano{#2}};
  \node [left of = NODOG, node distance =  \xdistancia] (VARIABLE) {\tamano{#1}};  	
	\draw [-latex, \colorlinea] (VARIABLE) -- (NODOG);
	\draw [-latex, \colorlinea] (NODOG) -| (SUMA);			
	\node  at (SUMA) [anchor = west] (NODO1) {};
}


\newcommand{\bMinusF}[1]{
	\node [draw=\colorlinea, circle,minimum size=1.5em, right of=NODO1, node distance=\xdistancia,\ancholinea, fill=\colorfondo,
	       drop shadow={opacity=\sombra}] (#1) {};
  \node [draw, cross out, minimum size=1.0em, right of=NODO1, node distance=\xdistancia, thin, draw=gray!50] {};	
  \node [left of = #1, node distance = 0.45em] () { \color{\colortexto}\tiny{$+$}};
  \node [below of = #1, node distance = 0.45em] () { \color{\colortexto}\tiny{$-$}};
	\draw [-latex, \colorlinea] (NODO1) -- (#1);			
	\node  at (#1) [anchor = west] (NODO1) {};	
	
}

%段宇 2016.1.8 开始左文本的圆
\newcommand{\bStartC}[2]{
	\node [draw=\colorlinea, circle,minimum size=1.0em,node distance=\xdistancia,\ancholinea, fill=\colorfondo,
	       drop shadow={opacity=\sombra}] (#2) {};
    \node [left of=#2] (NODO2) {\tamano{#1}};		   				
	\node  at (#2.east) [anchor = east] (NODO1) {};
}

%段宇 2016.1.8 向右的圆（前线上有文本）
\newcommand{\bGainC}[2]{		
	\node [draw=\colorlinea, circle, right of = NODO1, minimum size=1.0em,node distance=2.0cm,\ancholinea, fill=\colorfondo,
	       drop shadow={opacity=\sombra}] (NODO2) {};	
	\draw [-latex,\colorlinea] (NODO1)--(NODO2);
	\draw (NODO2) +(0,0.2) node [above]{#1};
	\draw (NODO1) +(0.8,0) node [above]{#2};
	\node  at (NODO2.east) [anchor = east] (NODO1) {};	
}

%段宇 2016.1.8 带箭头向右的圆（坐标定位）
\newcommand{\bCircle}[1]{
	\node [draw=\colorlinea, circle,minimum size=1.0em, right of=NODO1, node distance=\xdistancia,\ancholinea, fill=\colorfondo,
	       drop shadow={opacity=\sombra}] (#1) {};	
	\draw [-latex, \colorlinea] (NODO1) -- (#1);			
	\draw (#1) +(-0.09,0) node [anchor = west] (NODO1) {};	
	
}

%段宇 2016.1.8 带箭头向右的圆,上方有一指向它的圆（上有文本）（右有文本）（前线有文本）（下有文本）
\newcommand{\bCircleUp}[4]{
	\node [draw=\colorlinea, circle,minimum size=1.0em, right of=NODO1, node distance= 2.0cm,\ancholinea, fill=\colorfondo,
	       drop shadow={opacity=\sombra}] (SUMA) {};
	\draw [-latex, \colorlinea] (NODO1) -- (SUMA);
	\node [draw=\colorlinea, circle,minimum size=1.0em, above of = SUMA, node distance = 1.8cm,\ancholinea, fill=\colorfondo,
	       drop shadow={opacity=\sombra}] (VARIABLE) {};	
	\draw [-latex, \colorlinea] (VARIABLE) -- (SUMA);
	\draw (NODO1) +(1.0,0) node [above]{#1};
	\draw (VARIABLE) +(0,0.5)  node {#2};
	\draw (VARIABLE) +(0,-0.6) node [right]{#3};
	\draw (SUMA) +(0.3,-0.1) node [below]{#4};
	\draw (SUMA) +(-0.09,0) node [anchor = west] (NODO1) {};	
}

%段宇 2016.1.9 反馈增益标记圆（前线上加文本,后加文本）
\newcommand{\bSignC}[3]{
	\node [draw=\colorlinea, circle, right of = NODO1, minimum size=1.0em,node distance=\xdistancia,\ancholinea, fill=\colorfondo,
	       drop shadow={opacity=\sombra}] (#2) {};	
	\draw [-latex,\colorlinea] (NODO1)--(#2);
	\draw (NODO1) +(0.6,0) node [above]{#1};
	\node [right of = #2]{#3};
	\node  at (#2.east) [anchor = east] (NODO1) {};
	
}

%段宇 2016.1.9 大反馈增益标记圆（前线上加文本,后加文本）
\newcommand{\bBigSignC}[3]{
	\node [draw=\colorlinea, circle, right of = NODO1, minimum size=1.0em,node distance=4.0cm,\ancholinea, fill=\colorfondo,
	       drop shadow={opacity=\sombra}] (#2) {};	
	\draw [-latex,\colorlinea] (NODO1)--(#2);
	\draw (NODO1) +(1.8,0) node [above]{#1};
	\node [right of = #2]{#3};
	\node  at (#2.east) [anchor = east] (NODO1) {};
	
}

%段宇 2016.1.9 反馈增益标记方形（前线上加文本,下加文本）
\newcommand{\bSignR}[3]{
	\node [draw=\colorlinea, rectangle, right of = NODO1, minimum size=1.0em,node distance=1.0cm,\ancholinea, fill=\colorfondo,
	       drop shadow={opacity=\sombra}] (#2) {};	
	\draw [-latex,\colorlinea] (NODO1)--(#2);
	\draw (NODO1) +(0.5,0) node [above]{#1};
	\draw (#2) +(0,-0.1) node [below]{#3};
	\node  at (#2.east) [anchor = east] (NODO1) {};
	
}


%段宇 2016.1.9 反馈增益标记圆（前线上加文本,上加文本）
\newcommand{\bSignCUp}[3]{
	\node [draw=\colorlinea, circle, right of = NODO1, minimum size=1.0em,node distance=\xdistancia,\ancholinea, fill=\colorfondo,
	       drop shadow={opacity=\sombra}] (#2) {};	
	\draw [-latex,\colorlinea] (NODO1)--(#2);
	\draw (NODO1) +(0.6,0) node [above]{#1};
	\draw (#2) +(0,0.1) node [above]{#3};
	\node  at (#2.east) [anchor = east] (NODO1) {};
	
}

%段宇 2016.1.9 反馈增益标记圆（前线下加文本,下加文本）
\newcommand{\bSignCDown}[3]{
	\node [draw=\colorlinea, circle, right of = NODO1, minimum size=1.0em,node distance=\xdistancia,\ancholinea, fill=\colorfondo,
	       drop shadow={opacity=\sombra}] (#2) {};	
	\draw [-latex,\colorlinea] (NODO1)--(#2);
	\draw (NODO1) +(0.6,0) node [below]{#1};
	\draw (#2) +(0,-0.2) node [below]{#3};
	\node  at (#2.east) [anchor = east] (NODO1) {};
	
}

%段宇 2016.1.9自身循环（圆）加文本
\newcommand{\bLoopC}[2]{
\node [draw=\colorlinea, circle, right of = NODO1, minimum size=1.0em,node distance=\xdistancia,\ancholinea, fill=\colorfondo,
	       drop shadow={opacity=\sombra}] (NODO2){} edge [-latex, \colorlinea,in=120,out=60,loop] ();
		   \draw [-latex,\colorlinea] (NODO1)--(NODO2);
	\draw (NODO1) +(0.8,0) node [above]{#1};
	\draw (NODO2) +(0,0.7) node [right]{#2};
	\node  at (NODO2.east) [anchor = east] (NODO1) {};	
}

%段宇 2016.1.9 反馈增益圆加文本下右
\newcommand{\bFeedBackSC}[4]{
		
\node [draw=\colorlinea, circle,minimum size=1.0em, below left of=NODO1, node distance= 1.0cm,\ancholinea, fill=\colorfondo,
	       drop shadow={opacity=\sombra}] (SUMA) {};
	\draw [-latex, \colorlinea] (NODO1) -- (SUMA);
	\node [draw=\colorlinea, circle,minimum size=1.0em, below right of = SUMA, node distance = 1.5cm,\ancholinea, fill=\colorfondo,
	       drop shadow={opacity=\sombra}] (VARIABLE) {};	
	\draw [-latex, \colorlinea] (VARIABLE) -- (SUMA);
	\draw (NODO1) +(-0.2,-0.4) node [below]{#1};
	\draw (VARIABLE) +(0.3,-0.5)  node {#2};
	\draw (VARIABLE) +(-0.6,0.3) node {#3};
	\draw (SUMA) +(-0.4,0.3) node {#4};
	\draw (SUMA) +(0,0) node [anchor = west] (NODO1) {};
}



%段宇 2016.1.9 反馈增益弧线加文本下左
\newcommand{\bFeedBackC}[5]{		
\draw [-latex, \colorlinea] (NODO1)+(-0.2,-0.1) to [out=#4,in=#5] (#1);
\draw (NODO1) + #3 node [above]{#2};
}

%段宇 2016.1.9 反馈增益弧线加文本上左
\newcommand{\bFeedBackCUpL}[5]{		
\draw [-latex, \colorlinea] (NODO1)+(-0.2,0.1) to [out=#4,in=#5] (#1);
\draw (NODO1) + #3 node [above]{#2};
}

%段宇 2016.1.9 反馈增益弧线加文本上右
\newcommand{\bFeedBackCUp}[5]{
\draw (NODO1) +(-0.1,0) node [](NODOG){};
\draw [-latex, \colorlinea]  (#1) to [out=#4,in=#5](NODOG);
\draw (NODO1) + #3 node [above]{#2};
}


%段宇 2016.1.8 结束圆（前线有文本，后有文本）
\newcommand{\bEndC}[2]{		
	\node [draw=\colorlinea, circle, right of = NODO1, minimum size=1.0em,node distance=\xdistancia,\ancholinea, fill=\colorfondo,
	       drop shadow={opacity=\sombra}] (NODO2) {};	
	\draw [-latex,\colorlinea] (NODO1)--(NODO2);
	\draw (NODO1) +(0.6,0) node [above]{#1};
	\node [right of = NODO2]{#2};
	\node  at (NODO2.east) [anchor = east] (NODO1) {};	
}

%段宇 2016.1.8 同是减（向上）
\newcommand{\bMinusMUp}[1]{
	\node [draw=\colorlinea, circle,minimum size=1.5em, right of=NODO1, node distance=\xdistancia,\ancholinea, fill=\colorfondo,
	       drop shadow={opacity=\sombra}] (#1) {};
  \node [draw, cross out, minimum size=1.0em, right of=NODO1, node distance=\xdistancia, thin, draw=gray!50] {};	
  \node [left of = #1, node distance = 0.45em] () { \color{\colortexto}\tiny{$-$}};
  \node [below of = #1, node distance = -0.45em] () { \color{\colortexto}\tiny{$-$}};
	\draw [-latex, \colorlinea] (NODO1) -- (#1);			
	\node  at (#1) [anchor = west] (NODO1) {};	
	
}

%段宇 2016.1.8 三向下反馈（下减上加）
\newcommand{\bMinusFP}[1]{
	\node [draw=\colorlinea, circle,minimum size=1.5em, right of=NODO1, node distance=\xdistancia,\ancholinea, fill=\colorfondo,
	       drop shadow={opacity=\sombra}] (#1) {};
  \node [draw, cross out, minimum size=1.0em, right of=NODO1, node distance=\xdistancia, thin, draw=gray!50] {};	
  \node [left of = #1, node distance = 0.45em] () { \color{\colortexto}\tiny{$+$}};
  \node [below of = #1, node distance = 0.45em] () { \color{\colortexto}\tiny{$-$}};
  \node [below of = #1, node distance = -0.45em] () { \color{\colortexto}\tiny{$+$}};
	\draw [-latex, \colorlinea] (NODO1) -- (#1);			
	\node  at (#1) [anchor = west] (NODO1) {};	
	
}

%段宇 2016.1.7 上反馈（减）
\newcommand{\bMinusFUp}[1]{
	\node [draw=\colorlinea, circle,minimum size=1.5em, right of=NODO1, node distance=\xdistancia,\ancholinea, fill=\colorfondo,
	       drop shadow={opacity=\sombra}] (#1) {};
  \node [draw, cross out, minimum size=1.0em, right of=NODO1, node distance=\xdistancia, thin, draw=gray!50] {};	
  \node [left of = #1, node distance = 0.45em] () { \color{\colortexto}\tiny{$+$}};
  \node [below of = #1, node distance =-0.45em] () { \color{\colortexto}\tiny{$-$}};
	\draw [-latex, \colorlinea] (NODO1) -- (#1);			
	\node  at (#1) [anchor = west] (NODO1) {};	
	}


\newcommand{\bPlusF}[1]{
	\node [draw=\colorlinea, circle,minimum size=1.5em, right of=NODO1, node distance=\xdistancia,\ancholinea, fill=\colorfondo,
	       drop shadow={opacity=\sombra}] (#1) {};
  \node [thin, cross out, minimum size=1.0em, right of=NODO1, node distance=\xdistancia, draw=gray!50] {};	
  \node [left of = #1, node distance = 0.45em] () { \color{\colortexto}\tiny{$+$}};
  \node [below of = #1, node distance = 0.45em] () { \color{\colortexto}\tiny{$+$}};
	\draw [-latex, \colorlinea] (NODO1) -- (#1);			
	\node  at (#1) [anchor = west] (NODO1) {};	
	
}

%段宇 2016.1.7 上反馈（加）
\newcommand{\bPlusFUp}[1]{
	\node [draw=\colorlinea, circle,minimum size=1.5em, right of=NODO1, node distance=\xdistancia,\ancholinea, fill=\colorfondo,
	       drop shadow={opacity=\sombra}] (#1) {};
  \node [thin, cross out, minimum size=1.0em, right of=NODO1, node distance=\xdistancia, draw=gray!50] {};	
  \node [left of = #1, node distance = 0.45em] () { \color{\colortexto}\tiny{$+$}};
  \node [below of = #1, node distance = -0.45em] () { \color{\colortexto}\tiny{$+$}};
	\draw [-latex, \colorlinea] (NODO1) -- (#1);			
	\node  at (#1) [anchor = west] (NODO1) {};	
	
}

%段宇 2016.1.7 下反馈（加减）
\newcommand{\bPMF}[1]{
	\node [draw=\colorlinea, circle,minimum size=1.5em, right of=NODO1, node distance=\xdistancia,\ancholinea, fill=\colorfondo,
	       drop shadow={opacity=\sombra}] (#1) {};
  \node [thin, cross out, minimum size=1.0em, right of=NODO1, node distance=\xdistancia, draw=gray!50] {};	
  \node [left of = #1, node distance = 0.45em] () { \color{\colortexto}\tiny{$+$}};
  \node [below of = #1, node distance = 0.45em] () { \color{\colortexto}\tiny{$\pm$}};
	\draw [-latex, \colorlinea] (NODO1) -- (#1);			
	\node  at (#1) [anchor = west] (NODO1) {};	
	
}

%段宇 2016.1.7 上反馈（加减）
\newcommand{\bPMFUp}[1]{
	\node [draw=\colorlinea, circle,minimum size=1.5em, right of=NODO1, node distance=\xdistancia,\ancholinea, fill=\colorfondo,
	       drop shadow={opacity=\sombra}] (#1) {};
  \node [thin, cross out, minimum size=1.0em, right of=NODO1, node distance=\xdistancia, draw=gray!50] {};	
  \node [left of = #1, node distance = 0.45em] () { \color{\colortexto}\tiny{$+$}};
  \node [below of = #1, node distance = -0.45em] () { \color{\colortexto}\tiny{$\pm$}};
	\draw [-latex, \colorlinea] (NODO1) -- (#1);			
	\node  at (#1) [anchor = west] (NODO1) {};	
	
}

\newcommand{\bFeedBack}[2]{		
	\node [draw=\colorlinea, rectangle, below left of = NODO1, node distance =  \ydistancia, minimum height = \minaltura,\ancholinea, 
         fill=\colorfondo,drop shadow={opacity=\sombra}, anchor = west] (NODOG) {\color{\colortexto}\tamano{#1}};	
  \draw [-latex, \colorlinea] (NODO1) -- +(0.5,0) |- (NODOG);
	\draw [-latex, \colorlinea] (NODOG) -| (#2);     	
}

%段宇 2016.1.7 反馈增益前线加文本
\newcommand{\bFeedBackLine}[3]{		
	\node [draw=\colorlinea, rectangle, below left of = NODO1, node distance =  \ydistancia, minimum height = \minaltura,\ancholinea, 
         fill=\colorfondo,drop shadow={opacity=\sombra}, anchor = west] (NODOG) {\color{\colortexto}\tamano{#1}};	
  \draw [-latex, \colorlinea] (NODO1) -- +(0.5,0) |- (NODOG);
	\draw [-latex, \colorlinea] (NODOG) -| (#2);
\draw (NODOG) +(-3.0,0) node [below]{#3};	
}

%段宇 2016.1.12 双反馈增益
\newcommand{\bFeedBackT}[3]{		
	\node [draw=\colorlinea, rectangle, below left of = NODO1, node distance =  \ydistancia, minimum height = \minaltura,\ancholinea, 
         fill=\colorfondo,drop shadow={opacity=\sombra}, anchor = west] (NODOG) {\color{\colortexto}\tamano{#1}};
	\node [draw=\colorlinea, rectangle, left of = NODOG, node distance = 2.5cm, minimum height = \minaltura,\ancholinea, 
         fill=\colorfondo,drop shadow={opacity=\sombra}, anchor = west] (NODOH) {\color{\colortexto}\tamano{#2}};		 
  \draw [-latex, \colorlinea] (NODO1) -- +(0.5,0) |- (NODOG);
	\draw [-latex, \colorlinea] (NODOG) -- (NODOH);
		\draw [-latex, \colorlinea] (NODOH) -| (#3);	
}

%段宇 2016.1.12 反馈增益相加圆
\newcommand{\bFeedBackP}[2]{		
		\node [draw=\colorlinea, circle,minimum size=1.5em,below left of=NODO1, node distance= \ydistancia,\ancholinea, fill=\colorfondo,
	       drop shadow={opacity=\sombra}] (SUMA) {};
  \node [draw=gray!50, cross out, minimum size=1.0em, below left of=NODO1, node distance= \ydistancia, thin, draw=gray!50] {};	
  \node [left of = SUMA, node distance =-0.45em] () { \color{\colortexto}\tiny{$+$}};
  \node [above of = SUMA, node distance =-0.45em] () { \color{\colortexto}\tiny{$+$}};	
	\node [below of = SUMA, node distance =  \ydistancia] (VARIABLE) {\tamano{#1}};	 
	\draw [-latex, \colorlinea] (NODO1) -- +(0.5,0) |- (SUMA);
	\draw [-latex, \colorlinea] (VARIABLE) -- (SUMA);
		\draw [-latex, \colorlinea] (SUMA) -| (#2);	
}

%段宇 2016.1.12 反馈增益相加圆加反馈前线加文本
\newcommand{\bFeedBackTP}[4]{		
		\node [draw=\colorlinea, circle,minimum size=1.5em,below right of=NODO1, node distance= 1.0cm,\ancholinea, fill=\colorfondo,
	       drop shadow={opacity=\sombra}] (SUMA) {};
  \node [draw=gray!50, cross out, minimum size=1.0em, below right of=NODO1, node distance= 1.0cm, thin, draw=gray!50] {};	
  \node [left of = SUMA, node distance =-0.45em] () { \color{\colortexto}\tiny{$+$}};
  \node [above of = SUMA, node distance =0.45em] () { \color{\colortexto}\tiny{$+$}};	
	\node [right of = SUMA, node distance =  \xdistancia] (VARIABLE) {\tamano{#1}};	
\node [draw=\colorlinea, rectangle, below left of = NODO1, node distance =  2.0cm, minimum height = \minaltura,\ancholinea, 
         fill=\colorfondo,drop shadow={opacity=\sombra}, anchor = west] (NODOG) {\color{\colortexto}\tamano{#2}};	
	\draw [-latex, \colorlinea] (NODO1) -- +(0.7,0) -- (SUMA);
	\draw [-latex, \colorlinea] (VARIABLE) -- (SUMA);
	\draw [-latex, \colorlinea] (SUMA)|- (NODOG);
		\draw [-latex, \colorlinea] (NODOG) -| (#3);
\draw (NODOG) +(-3.5,0) node [below]{#4};		
}




%段宇 2016.1.7 反馈增益翻向上边
\newcommand{\bFeedBackUp}[2]{		
	\node [draw=\colorlinea, rectangle, below right of = NODO1, node distance =  -\ydistancia, minimum height = \minaltura,\ancholinea, 
         fill=\colorfondo,drop shadow={opacity=\sombra}, anchor = west] (NODOG) {\color{\colortexto}\tamano{#1}};	
  \draw [-latex, \colorlinea] (NODO1) -- +(0.5,0) |- (NODOG);
	\draw [-latex, \colorlinea] (NODOG) -| (#2);     	
}

%段宇 2016.1.7 反馈增益翻向上边向右
\newcommand{\bFeedBackUpR}[2]{		
	\node [draw=\colorlinea, rectangle, below left of = NODO1, node distance =  -\ydistancia, minimum height = \minaltura,\ancholinea, 
         fill=\colorfondo,drop shadow={opacity=\sombra}, anchor = west] (NODOG) {\color{\colortexto}\tamano{#1}};	
  \draw [-latex, \colorlinea] (NODO1) -- +(0.5,0) |- (NODOG);
	\draw [-latex, \colorlinea] (NODOG) -| (#2);     	
}

%段宇 2016.1.7 向下直接反馈画线不加增益
\newcommand{\bFeedBackNo}[1]{\draw [-latex, \colorlinea] (NODO1) -- +(0.5,0) |- +(0,-\ydistancia) -|(#1);}

%段宇 2016.1.7 向上直接反馈画线不加增益
\newcommand{\bFeedBackNoUp}[1]{\draw [-latex, \colorlinea] (NODO1) -- +(0.5,0) |- +(0,\ydistancia) -|(#1);}

%段宇 2016.1.8 坐标定位
\newcommand{\bPoint}[3]{
	\node at #2 (#3) {\tamano{#1}};
}

\newcommand{\bCrossGain}[3]{		
	\node [draw=\colorlinea, rectangle, above right of = #2, minimum height = \minaltura,\ancholinea, 
         fill=\colorfondo,drop shadow={opacity=\sombra}, anchor = west] (NODOG) {\color{\colortexto}\tamano{#1}};	
  \draw [-latex, \colorlinea] (#2) |- (NODOG);
	\draw [-latex, \colorlinea] (NODOG) -| (#3);     	
}

%段宇 2016.1.9 双线开始文本
\newcommand{\bTStart}[2]{
    \node [] (NODO1) {\tamano{#1}};
	\draw (NODO1) +(0,-0.6) node (NODO2) {#2};
}

%段宇 2016.1.9 双线增益可加文本
\newcommand{\bTGainLine}[2]{		
	\node [draw=\colorlinea, rectangle, right of = NODO1, node distance= 4.0cm, minimum height = 2.0cm, 
	       \ancholinea, fill=\colorfondo,drop shadow={opacity=\sombra}] (NODO3) { \color{\colortexto}\tamano{#1}};	
	\draw [-latex, \colorlinea] (NODO1)--(NODO3);
	\draw (NODO3) +(-0.5,-0.6) node (G) {};
	\draw [-latex, \colorlinea] (NODO2)--(G);
	\draw (NODO1) +(1.8,0) node [above]{#2};
	\node  at (NODO3.east) [anchor = east] (NODO1) {};	
}

%段宇 2016.1.9 双线结束文本
\newcommand{\bTEnd}[3]{
	\node [right of = NODO1, node distance =3.5cm] (F) {#1};
	\draw (F) +(0,-0.6) node (E) {#2};
		\draw (NODO1) +(1.5,0) node [above]{#3};
	\draw [-latex,\colorlinea] (NODO1) -- (F);
	\draw [-latex,\colorlinea] (NODO1)+(0.1,-0.6) -- (E);
	\node  at (F) [anchor = west] (NODO1) {};
	\node  at (E) [anchor = west] (NODO2) {};
}

\newcommand{\bNewStart}[2]{
	\node at #2 (NODO1) {\tamano{#1}};
}


\newcommand{\bMarkNode}[1]{
	\node at (NODO1) (#1) {};
}


\newcommand{\bMarkNodeUp}[1]{
	\node[above of = NODO1, node distance =  \ydistancia] (#1) {};
}


\newcommand{\bMarkNodeDown}[1]{
	\node[below of = NODO1,node distance =  \ydistancia] (#1) {};
}

\newcommand{\bT}
{[shorten >=1pt,node distance=2cm]
\node[state,initial] (q0) {$q_0$};
\node[state] (q1) [right of=q0] {$q_1$};
\node[state,accepting](q2) [right of=q1] {$q_2$};
\path[->] (q0) edge node [above] {0} (q1);
edge [loop above] node {1} ();
edge [bend left] node [above] {1} (q2);
edge [bend right] node [below] {0} (q2);
(q1) edge node [above] {1} (q2);
}